#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    vector<int> twoSum(vector<int>& nums, int target) {
        map<int, int> hash;
        vector<int> ans(2, -1);
        for (int i = 0; i < nums.size(); i++)
        {
            hash.insert(pair<int, int>(nums[i], i));
        }

        for (int i = 0; i < nums.size(); i++)
        {
            if (hash.count(target - nums[i]) > 0 &&
                hash[target - nums[i]] != i)
            {
                ans[0] = i;
                ans[1] = hash[target - nums[i]];
                break;
            }
        }
        return ans;
    }
};